<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

class CompanyRegList
{
    public $login = true; //是否需要登录才能访问该接口
    public $title = "005单位申请列表ok";
    public $group = '租房';
    public $desc = "";

    public $input = [
        'page_num' => 'int;label=分页;comment=默认为1',
        'page_size' => 'int;label=分页条数;comment=默认为5',
    ];

    public $output = [
        'page_num' => 'label=当前页码;',
        'page_size' => 'label=每页条数;',
        'page_count' => 'label=总条数;',
        'page_total' => 'label=总页数;',
        'list' => [
            [
                'id' => 'label=id;',
                'company' => 'label=工作单位;',
                'company_contact' => 'label=公司经办人姓名;',

                'company_mobile' => 'label=公司经办人联系电话;',
                'contact_real_name' => 'label=通讯联系人姓名;',
                'contact_idcard' => 'label=通讯人身份证;',
                'contact_address' => 'label=通讯人地址;',
                'state' => 'label=状态: 1提交申请 2内部审批 3审批成功 4审批失败 5取消审批;',
                'create_time' => 'label=申请时间;',
            ]
        ]
    ];

    public function run($param, $uid)
    {
        $page_num = $param['page_num'] ?: 1;
        $page_size = $param['page_size'] ?: 10;

        $list = M('company_reg')
            ->where([
                'uid' => $uid,
            ])
            ->order('id desc')->page($page_num, $page_size)
            ->select();
        $count = M('company_reg')
            ->where([
                'uid' => $uid,
            ])->count();
        return [
            'list'=> $list,
            'page_count' => $count,
            'page_total' => ceil($count / $page_size)
        ];
    }
}
